package longshu.data.domain;

import lombok.experimental.Accessors;
import longshu.data.common.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * @author LongShu
 * @since 2018-02-03
 */
@lombok.Getter
@lombok.Setter
@Accessors(chain = true)
@lombok.NoArgsConstructor
@Table(name = "province_city_area")
public class ProvinceCityArea extends BaseEntity {

    public ProvinceCityArea(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 行政区划代码
     */
    @Column(name = "code", unique = true, nullable = false)
    private Integer code;

    /**
     * 名称
     */
    @Column(name = "name", nullable = false, length = 16)
    private String name;

    /**
     * parentCode
     */
    @Column(name = "pc")
    private Integer pc;

    private static final long serialVersionUID = 1L;

    @Override
    public String toString() {
        if (pc == null) {
            return code + "," + name;
        }
        return code + "," + name + "," + pc;
    }

}